package com.css.dzj.dzjap.common.menu;

import com.css.dzj.dzjap.common.util.R;
import com.css.dzj.dzjap.sys.user.entity.LoginUser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
@RequestMapping("/user")
public class GetUserInfoController {
    @GetMapping("/getuser")
    public R getUserInfoByRequest(HttpServletRequest request) {
        HttpSession loginSession = request.getSession();
        if (loginSession == null || (loginSession.getAttribute("_USER_LOGIN_INFO_") == null)) {
            return R.error("session缺失");
        }
        LoginUser userInfo = (LoginUser) loginSession.getAttribute("_USER_LOGIN_INFO_");
        return R.ok().put("data", userInfo);
    }
}
